var glob = require('glob');
function getEnv() {
	return process.env.PROXY?process.env.PROXY.trim():'dev';
}

exports.getProxyTarget = function(){
	let env = getEnv();
	console.log(env)
	let proxyTarget;
	switch(env){
		case 'dev':	//开发环境
		proxyTarget = 'http://csms-dev.evcard.vip/';
		break;
		case 'test': //测试环境
		proxyTarget = 'http://csms-test.evcard.vip/'
		break;
		case 'pre': //预发环境
		proxyTarget = 'http://csms-pre.evcard.vip/';
		break;
		case 'prod': //生产环境
		proxyTarget = 'http://csms.evcard.vip/';
		break;
	}
	return proxyTarget;
}

exports.getApiHost = function() {
	let env = getEnv();
	if(env == 'dev' || env == 'test' || env == 'prod'){
		return '/test/shortRent'
	}else{
		return '/shortRent'
	}
}

exports.getEntry = function getEntry(globPath) {
	var entries = {};
	if (typeof(globPath) != "object") {
			globPath = [globPath]
	}
	globPath.forEach((itemPath) => {

			glob.sync(itemPath).forEach(function(entry) {
					entries[entry.substring(13, entry.lastIndexOf('.'))] = entry; // 13代表'./src/module/'
			});
	});

	return entries;
};